<!--单行文本-->
<template>
  <el-rate
    v-model="value"
    v-bind="$attrs"
    :id="'c' + formItemMeta.columnId"
    :name="'c' + formItemMeta.columnId"
    :clearable="clearable"
  >
  </el-rate>
  <circle-close-filled v-if="clearable"
    style="width: 1.2em; height: 1.2em; margin-top: -2px; margin-left: 5px;cursor: pointer;"
    @click.stop="myclear" 
  />
</template>

<script lang="ts">
  import { defineComponent } from 'vue'
  // import { ElRate } from 'element-plus'
  import { CircleCloseFilled } from '@element-plus/icons-vue'
  // 引入组件需要的属性 引入表单子控件的管理类
  import { itemProps, itemController } from '../map'

  // 五星评分
  export default defineComponent({
    name: 'nf-el-form-item-rate',
    inheritAttrs: false,
    components: {
      // ElRate,
      CircleCloseFilled
    },
    props: {
      ...itemProps, // 基础属性
      modelValue: [String, Number]
    },
    emits: ['update:modelValue'],
    setup (props, context) {
      const {
        value
      } = itemController(props, context.emit)

      const myclear = () => {
        value.value = null
      }

      return {
        value,
        myclear
      }
    }
  })
</script>
